import queue
import threading
from playwright.sync_api import sync_playwright


def worker():
    while True:
        item = q.get()
        # 模拟任务处理
        with sync_playwright() as p:
            p = p.chromium.launch(headless=False)
            with p.new_context() as context:
                page = context.new_page()
                page.goto("https://fe-bigevent-web.itheima.net/login")
                page.pause()
                # page.locator('')
        print(f"Processing {item}")
        q.task_done()


q = queue.Queue()
threads = []
for _ in range(3):
    t = threading.Thread(target=worker)
    t.start()
    threads.append(t)

for i in range(10):
    q.put(i)

q.join()
for t in threads:
    t.join()

